import { MeetingRoom } from "../../meeting-room/entities/meeting-room.entity";
import { User } from "../../user/entities/user.entity";
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";


@Entity()
export class Booking {
   
    @PrimaryGeneratedColumn()
    id:number;

    @Column({
        comment: '会议开始时间'
    })
    startTime: Date;

    @Column({
        comment: '会议结束时间'
    })
    endTime: Date;

    @Column({
        length: 20,
        comment: '状态（申请中、审批通过、审批驳回、已解除）',
        default: '申请中'
    })
    status: string;

    @Column({
        length: 100,
        comment: '备注',
        default: ''
    })
    note: string;

    //Many是指Booking,One是指用户
    //一个用户可能查出很多个预定列表,所以是多对一
    //所以直接查这个表的User字段，可以出来很多个预定表
    @ManyToOne(() => User)
    user: User;

    //同样,一个会议室可能有很多个预定列表,很多次被申请
    //所以查会议室，可能出来很多预定列表
    @ManyToOne(() => MeetingRoom)
    room: MeetingRoom;

   
    @CreateDateColumn({
        comment: '创建时间'
    })
    createTime: Date;

    @UpdateDateColumn({
        comment: '更新时间'
    })
    updateTime: Date;
}
